package com.xunyin.modules.wechatshop.rest;

import com.xunyin.api.ApiResult;
import com.xunyin.modules.common.param.SettlementParam;
import com.xunyin.modules.log.AppLog;
import com.xunyin.modules.settlement.service.SettlementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 订单类controller
 * Copyright (C) 2022-2023
 * All rights reserved, Designed By www.tonetn.com
 * 注意：
 * 本软件为讯音云商开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
@Slf4j
@RestController
@Api(value = "订单结算相关接口", tags = "共享空间:订单结算相关接口")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ClientSettlementController {

    /**
     * 结算接口
     * */
    @Autowired
    private SettlementService settlementService;

    /**
     * 订单结算
     */
    @AppLog(value = "提交订单结算", type = 1)
    @PostMapping("settlement/submit")
    @ApiOperation(value = "提交订单结算", notes = "提交订单结算")
    public ApiResult<Map<String, Object>> submit(HttpServletRequest request, @RequestBody SettlementParam param) {

        Map<String, Object> result = settlementService.doSubmit(request, param);
        return ApiResult.ok(result);

/*        try {
            Map<String, Object> result = settlementService.doSubmit(request, param);
            return getSuccessResult(result);
        } catch (BusinessCheckException e) {
            return getFailureResult(201, e.getMessage());
        }*/
    }
}
